function RegWriteStringValue(const RootKey: Integer; const SubKeyName, ValueName, Data: String): Boolean;
Writes the specified REG_SZ-type registry value. Returns True if successful, False otherwise.
If the value already exists and is of type REG_EXPAND_SZ, the new value will also be of type REG_EXPAND_SZ. Otherwise, a REG_SZ-type value will be created.
begin RegWriteStringValue(HKEY_CURRENT_USER, 'Software\My Company\My Program', 'UserName', ExpandConstant('{sysuserinfoname}')); end;